<style scoped>
.container {
  padding: 16px;
  border: 1px solid #efefef;
}
.ruleForm {
  width: 80%;
}
.columnItem {
  display: inline-block;
  margin: 5px;
  float: left;
}
.box-card {
  margin-bottom: 20px;
}
.el-card__body {
  height: auto !important;
}
</style>

<!-- 页面布局-->
<template>
  <div class="table">
    <!-- 主体区 -->
    <div class="container">
      <!-- 表单区 -->
      <div class="form-data-box">
        <el-form
          :model="formBean"
          :rules="validateRules"
          ref="form1"
          label-width="150px"
          class="ruleForm"
        >
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>基础配置</span>
            </div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产任务号" prop="produceCode">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.produceCode"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="运营商编码" prop="ispCode">
                  <!-- <el-input :readonly="readOnly" v-model="formBean.ispCode"></el-input> -->
                  <el-select
                    clearable
                    :disabled="readOnly"
                    v-model="formBean.ispCode"
                    placeholder="运营商"
                    @change="ispChange"
                  >
                    <el-option
                      v-for="item in ispList"
                      :key="item.ispCode"
                      :label="item.ispName"
                      :value="item.ispCode"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="虚商编码" prop="vopCode">
                  <!-- <el-input :readonly="readOnly" v-model="formBean.vopCode"></el-input> -->
                  <el-select
                    clearable
                    :disabled="readOnly"
                    v-model="formBean.vopCode"
                    placeholder="虚商"
                    @change="changeVop"
                  >
                    <el-option
                      v-for="item in vopList"
                      :key="item.vopCode"
                      :label="item.vopName"
                      :value="item.vopCode"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="制卡类型" prop="dataformatNo">
                  <el-select clearable :disabled="readOnly" v-model="formBean.dataformatNo" placeholder="卡类型" >
                  <el-option label="成卡" value="0" ></el-option>
                  <el-option label="白卡" value="1" ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="合同号" prop="contractCode">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.contractCode"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="生产任务名称" prop="produceName">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.produceName"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="个人化指令工具" prop="personalTool">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.personalTool"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-card class="box-card" style="height: 191px">
            <div slot="header" class="clearfix">
              <span>MCA模板配置</span>
              <el-button
                style="float: right; margin-right: 28px"
                @click="toMcaAdd"
                type="primary"
                >新增</el-button
              >
            </div>
            <el-row>
              <el-col :span="actType == 'view' ? 24 : 21">
                <el-form-item label="MCA文件模板" prop="mcaTemplateId">
                  <el-select
                    clearable
                    :disabled="readOnly"
                    v-model="formBean.mcaTemplateId"
                    placeholder="虚商"
                    @change="toChaneMca"
                  >
                    <el-option
                      v-for="item in mcaTemplateAllList"
                      :key="item.mcaTemplateId"
                      :label="item.mcaTemplateName"
                      :value="item.mcaTemplateId"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col
                :span="2"
                style="text-align: right"
                v-if="actType !== 'view'"
              >
                <el-button @click="toMcaUpd" type="primary">修改</el-button>
              </el-col>
              <!-- <el-col
                :span="2"
                style="text-align: right"
                v-if="actType !== 'view'"
              >
                <el-button @click="toMcaAdd" type="primary">新增</el-button>
              </el-col> -->
            </el-row>
            <el-row>
              <el-col>
                <div
                  v-for="(column, index) in mcaTemplateDetailList"
                  :key="index"
                  sortable
                  class="columnItem"
                >
                  {{ column.columnName
                  }}{{ index != mcaTemplateDetailList.length - 1 ? "," : null }}
                </div>
              </el-col>
            </el-row>
          </el-card>
          <el-card class="box-card" body-style="min-height: 300px">
            <div slot="header" class="clearfix">
              <span>虚商个性化输出明细数据模板</span>
              <el-button
                style="float: right; margin-right: 28px"
                @click="toFileAdd"
                type="primary"
                >新增</el-button
              >
            </div>
            <el-row style="margin: 10px">
              <el-table
                border
                min-height="200"
                stripe
                :header-cell-style="{
                  background: '#F3F3F3',
                  color: '#606266',
                }"
                ref="fileTemTable"
                :data="allFileTemplateList"
                tooltip-effect="dark"
                style="width: 100%"
                @selection-change="handleSelectionChange"
              >
                <el-table-column type="selection" width="55"> </el-table-column>
                <template v-for="(column, i) in fileTemplateColumnData">
                  <el-table-column
                    :prop="column.columnCode"
                    :key="i"
                    sortable
                    :width="
                      column.columnCode == 'timestamp' ||
                      column.columnCode == 'produceCode'
                        ? '150'
                        : 'auto'
                    "
                    v-if="column.visiable == '1' || column.visiable == 1"
                    :label="column.columnName"
                    show-overflow-tooltip
                  >
                  </el-table-column>
                </template>
                <!-- <el-table-column prop="fileTemplateName" label="模板名称">
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" width="150">
                  <template slot-scope="scope">
                    <el-popover
                      placement="left"
                      width="180"
                      trigger="hover"
                      popper-class="applybatch-list-popover"
                    >
                      <div class="fxcol fxcc" style="margin: 10px 0">
                        <template v-for="item in rightButton">
                          <el-button
                            size="mini"
                            :key="item.ms_resource_id"
                            :type="item.type"
                            @click="handleClickMore(scope.row, item.method)"
                            :style="{
                              width: '135px',
                              margin:
                                item.ms_resource_id != '1' ? '10px 0 0 0' : '',
                            }"
                            >{{ item.name }}</el-button
                          >
                        </template>
                      </div>
                      <span slot="reference" style="cursor: pointer">更多</span>
                    </el-popover>
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
          </el-card>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>日期配置</span>
            </div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="有效期日期" prop="validDate">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.validDate"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="有效期年" prop="validYear">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.validYear"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="有效期月" prop="validMonth">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.validMonth"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="有效期日" prop="validDay">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.validDay"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>打印配置</span>
            </div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="其他打印" prop="printElse">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.printElse"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="版面" prop="cardFace">
                  <el-input
                    :readonly="readOnly"
                    v-model="formBean.cardFace"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>其他配置</span>
            </div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="限制规则" prop="rule">
                  <el-input
                    type="textarea"
                    :readonly="readOnly"
                    v-model="formBean.rule"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注" prop="memo">
                  <el-input
                    type="textarea"
                    :readonly="readOnly"
                    v-model="formBean.memo"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
        </el-form>
      </div>
      <!-- 表单区END -->
      <!-- 按钮操作区 -->
      <span slot="footer" class="form-btn-box">
        <el-button v-if="!readOnly" @click="resetForm('form1')"
          >重 置</el-button
        >
        <el-button
          v-if="!readOnly"
          type="primary"
          @click="submitForm('form1')"
          v-loading.fullscreen.lock="fullscreenLoading"
          >确 定</el-button
        >
        <el-button @click="cnacelForm('form1')">取 消</el-button>
      </span>
      <!-- 按钮操作区END -->
    </div>
    <!-- 主体区END -->
  </div>
</template>

<script>
import { validateMobile } from "common/validate";
import mcaTemplate from "./task_mcamanage_list";
import fileTemplate from "./task_filemanage_list";
export default {
  data() {
    return {
      // 提交表单的loading设置标识
      fullscreenLoading: false,
      firstLoadedData: "{}",
      // 新增用户表单信息
      formBean: {
        contractCode: "",
        produceCode: "",
        produceName: "",
        ispCode: "",
        dataformatNo: "",
        provinceCode: "",
        cityCode: "",
        validDate: "",
        validYear: "",
        validMonth: "",
        validDay: "",
        printElse: "",
        vopCode: "",
        personalTool: "",
        cardFace: "",
        rule: "",
        memo: "",
        mcaTemplateId: "",
        fileTemplateList: [],
      },
      fileTemplateList: [],
      vop: {
        vopName: "",
        pageIndex: "",
        pageRows: "",
      },
      vopList: [],
      isp: {
        ispName: "",
        pageIndex: "",
        pageRows: "",
      },
      ispList: [],
      cityList: [],
      provinceList: [],
      mcaTemplateAllList: [],
      mcaTemplateDetailList: [],
      fileTemplateName: "",
      allFileTemplateList: [], //文件名称
      rightButton: [
        {
          id: 3,
          tag: "cardApplyBatch_button_exportDetail",
          name: "修改",
          method: "toFileUpd",
          type: "primary",
        },
      ],
      // 表单校验规则
      validateRules: {
        contractCode: [
          { required: false, message: "请输入合同号", trigger: "blur" },
        ],
        produceCode: [
          { required: true, message: "请输入生产任务号", trigger: "blur" },
        ],
        produceName: [
          { required: false, message: "请输入生产任务名称", trigger: "blur" },
        ],
        ispCode: [
          {
            required: true,
            message: "请输入基础运营商编码",
            trigger: "blur",
          },
        ],
        vopCode: [
          { required: true, message: "请输入虚商编码", trigger: "blur" },
        ],
        dataformatNo: [
          { required: true, message: "请选择制卡类型", trigger: "blur" },
        ],
        personalTool: [
          {
            required: false,
            message: "请输入个人化指令工具",
            trigger: "blur",
          },
        ],
        cardFace: [{ required: false, message: "请输入版面", trigger: "blur" }],
        rule: [{ required: false, message: "请输入限制规则", trigger: "blur" }],
        memo: [{ required: false, message: "请输入备忘录", trigger: "blur" }],
        mcaTemplateId: [
          { required: true, message: "请输入MCA模板", trigger: "blur" },
        ],
      },
      //所选记录id
      selectedId: "",
      //事物类型
      actType: "",
      // 表单只读状态
      readOnly: false,
      readOnlyEdt: false,
      fileTemplateColumnData:[],  //文件模板表头
    };
  },
  // 进入页面加载数据
  // activated() {
  // 	this.handleInitLoad();
  // },
  //弹出页
  props: {
    sourceData: {
      required: true,
    },
  },
  // 进入页面加载数据
  mounted() {
    this.handleInitLoad();
  },

  methods: {
    /**
     * 组件初始化加载
     */
    handleInitLoad() {
      this.toloadVop();
      this.toloadIsp();
      // this.loadProvince();
      // this.loadCity();
      this.loadColumnData();
      this.initFormData();
    },

    /**
     * 取消返回
     * @augments formName 表单名称
     */
    cnacelForm(formName) {
      this.$refs[formName].resetFields();
      this.$emit("cancel", this.cancelData);
    },
    /**
     * 重置表单
     * @augments formName 表单名称
     */
    resetForm(formName) {
      this.formBean = JSON.parse(this.firstLoadedData);
    },
    /**
     *初始化加载表单数据
     */
    initFormData() {
      this.selectedId = this.sourceData.seleid;
      this.actType = this.sourceData.actType;
      this.readOnlyEdt = true;
      if (this.actType == "view") {
        // 查看状态 标识表单只读
        this.readOnly = true;
      } else if (this.actType == "add") {
        this.readOnly = false;
        this.readOnlyEdt = false;
        //清空修改保存之后数据还存在的情况
        for (var key in this.formBean) {
          this.formBean[key] = "";
        }
        return;
      } else {
        this.readOnly = false;
      }
      this.$axios
        .get(`/herp/cardProduce/${this.selectedId}/`, {
          headers: {
            operator: this.$util.getLoginer().userid,
            withCredentials: true,
          },
        })
        .then((res) => {
          this.formBean = {};
          if (res.data.success == true) {
            this.formBean = res.data.data;
            if (
              res.data.data.fileTemplateList &&
              res.data.data.fileTemplateList.length > 0
            ) {
              this.fileTemplateList = res.data.data.fileTemplateList;
            }
            console.log("this.fileTemplateList", this.fileTemplateList);
            this.firstLoadedData = JSON.stringify(this.formBean);
            this.loadMcaTemplateAll();
            this.loadfileTemplate(res.data.data.fileTemplateList);
          } else {
            this.$error(res.data.msg);
          }
        })
        .catch(function (error) {});
    },
    /**
     * 提交表单
     * @augments formName 表单名称
     */
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // 表单校验成功
          this.fullscreenLoading = true;
          let url = "",
            resultPromise;
          this.formBean.fileTemplateList = this.fileTemplateList.map((item) => {
            return { fileTemplateId: item.fileTemplateId };
          });
          console.log(this.formBean.fileTemplateList);
          if (this.actType == "add") {
            url = "/herp/produce/";
            resultPromise = this.$axios
              .post(url, this.formBean)
              .then((res) => {
                // 关闭提交表单的loading
                this.fullscreenLoading = false;
                let data = res.data;
                // 关闭提交表单的loading
                if (data.success) {
                  this.$message({
                    message: data.message,
                    type: "success",
                  });
                  this.$emit("ok", {});
                } else {
                  this.$error(data.message);
                }
              })
              .catch(function (error) {
                this.fullscreenLoading = false;
              });
          } else if (this.actType == "upd") {
            url = `herp/cardProduce/${this.selectedId}/`;
            this.$axios
              .put(url, this.formBean)
              .then((res) => {
                // 关闭提交表单的loading
                this.fullscreenLoading = false;
                let data = res.data;
                // 关闭提交表单的loading
                if (data.success) {
                  this.$message({
                    message: data.message || "修改成功",
                    type: "success",
                  });
                  this.$emit("ok", {});
                } else {
                  this.$error(data.message);
                }
              })
              .catch(function (error) {
                this.fullscreenLoading = false;
              });
          }
        }
      });
    },
    //加载虚商列表
    toloadVop() {
      this.$axios
        .get(`/herp/vop/`, {
          params: this.vop,
        })
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.vopList = data.data.list;
          } else {
            this.$error(data.message);
          }
        })
        .catch(function (error) {
          this.fullscreenLoading = false;
        });
    },
    //加载虚商列表
    toloadIsp() {
      this.$axios
        .get(`/herp/isp/`, {
          params: this.isp,
        })
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.ispList = data.data.list;
          } else {
            this.$error(data.message);
          }
        })
        .catch((error) => {
          this.$error(data.message);
        });
    },
    /**
     * 基础运营商改变
     */
    ispChange(isp) {
      if (isp == "") {
        this.formBean.ispCode = "";
        this.formBean.mcaTemplateId = "";
        this.mcaTemplateDetailList = [];
        this.allFileTemplateList = [];
        return false;
      }
      if (this.formBean.ispCode == "" || this.formBean.vopCode == "") {
        return false;
      }

      this.loadMcaTemplateAll();
      this.loadfileTemplate();
    },
    /**
     * 虚商改变
     */
    changeVop(vop) {
      if (vop == "") {
        this.formBean.vopCode = "";
        this.formBean.mcaTemplateId = "";
        this.mcaTemplateDetailList = [];
        this.allFileTemplateList = [];
        return false;
      }
      if (this.formBean.ispCode == "" || this.formBean.vopCode == "") {
        return false;
      }

      this.loadMcaTemplateAll();
      this.loadfileTemplate();
    },
    /**
     * 查询指定虚商下 mca 模板
     */
    loadMcaTemplateAll() {
      this.$axios
        .get(
          `/herp/vop/${this.formBean.vopCode}/isp/${this.formBean.ispCode}/mcaTemplate/`,
          {
            headers: {
              operator: this.$util.getLoginer().userid,
              withCredentials: true,
            },
          }
        )
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.mcaTemplateAllList = data.data;
            if (this.mcaTemplateAllList.length > 0) {
              if (this.formBean.mcaTemplateId) {
                this.mcaTemplateAllList.forEach((element) => {
                  if (element.mcaTemplateId == this.formBean.mcaTemplateId) {
                    this.fileTemplateName = element.fileTemplateName;
                  }
                });
                this.loadTemplateDetail(this.formBean.mcaTemplateId);
              } else {
                this.fileTemplateName = this.mcaTemplateAllList[0].fileTemplateName;
                this.formBean.mcaTemplateId = this.mcaTemplateAllList[0].mcaTemplateId;
                this.loadTemplateDetail(
                  this.mcaTemplateAllList[0].mcaTemplateId
                );
              }
            }
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    /**
     * 查询指定 mca 模板所有字段明细
     * @param item mca文件模板一条记录
     */
    loadTemplateDetail(mcaTemplateId) {
      this.$axios
        .get(`/herp/mcaTemplate/${mcaTemplateId}/`, {
          headers: {
            operator: this.$util.getLoginer().userid,
            withCredentials: true,
          },
        })
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.mcaTemplateDetailList = data.data;
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
          this.$error(err);
        });
    },
    /**
     * 新增mca模板文件
     */
    toMcaAdd() {
      if (this.formBean.vopCode == "" || this.formBean.ispCode == "") {
        this.$message("请选择基础运营商或虚商");
        return;
      }
      //页面参数
      var pageParam = {
        actType: "add",
        seleid: "0",
        vopId: this.formBean.vopCode,
        ispId: this.formBean.ispCode,
        fileTemplateName: "",
      };
      let commDialog = this.$dialog.commDialog(
        "新增MCA文件模板",
        mcaTemplate,
        pageParam,
        "800px",
        "500px"
      );
      commDialog.exec.then((data) => {
        if (data.type == "ok") {
          this.formBean.mcaTemplateId = data.data.mcaTemplateId;
        }
        this.loadMcaTemplateAll();
      });
    },
    /**
     * 修改mca模板文件
     */
    toMcaUpd() {
      //页面参数
      var pageParam = {
        actType: "upd",
        vopId: this.formBean.vopCode,
        ispId: this.formBean.ispCode,
        seleid: this.formBean.mcaTemplateId,
        fileTemplateName: this.fileTemplateName,
      };
      let commDialog = this.$dialog.commDialog(
        "修改MCA文件模板",
        mcaTemplate,
        pageParam,
        "800px",
        "500px"
      );
      commDialog.exec.then((data) => {
        if (data.type == "ok") {
          this.formBean.mcaTemplateId = data.data.mcaTemplateId;
        }
        this.loadMcaTemplateAll();
      });
    },
    /**
     * 切换mca文件模板
     */
    toChaneMca(val) {
      if (val == "") {
        this.mcaTemplateDetailList = [];
        return false;
      }
      this.loadTemplateDetail(this.formBean.mcaTemplateId);
      this.mcaTemplateAllList.forEach((item, index) => {
        if (item.mcaTemplateId == this.formBean.mcaTemplateId) {
          this.fileTemplateName = item.fileTemplateName;
          console.log("tag", this.fileTemplateName);
        }
      });
    },
    //加载省份
    loadProvince() {
      this.$axios
        .get(`/herp/province/`, {
          params: {
            isp: "cu",
          },
          headers: {
            operator: this.$util.getLoginer().userid,
            withCredentials: true,
          },
        })
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.provinceList = data.data.list;
            this.provinceCode = this.provinceList[0].provinceCode;
            this.loadCity();
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
          this.$error(err);
        });
    },
    proviceChange(val) {
      if (val == "") {
        this.cityList = [];
        this.cityCode = "";
        return false;
      }
      this.loadCity();
    },
    //加载省份
    loadCity() {
      this.$axios
        .get(`/herp/city/`, {
          params: {
            provinceId: this.formBean.provinceCode,
            pageIndex: "",
            pageRows: "",
          },
          headers: {
            operator: this.$util.getLoginer().userid,
            withCredentials: true,
          },
        })
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.cityList = data.data.list;
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
          this.$error(err);
        });
    },
    //虚商个性化输出明细数据模板
    loadfileTemplate() {
      this.$axios
        .get(
          `/herp/vop/${this.formBean.vopCode}/isp/${this.formBean.ispCode}/fileTemplate/`,
          {
            headers: {
              operator: this.$util.getLoginer().userid,
              withCredentials: true,
            },
          }
        )
        .then((res) => {
          let data = res.data;
          if (data.success) {
            this.allFileTemplateList = data.data;
            this.$nextTick(() => {
              let arrTmp = [];
              this.allFileTemplateList.forEach((item) => {
                this.fileTemplateList.forEach((row) => {
                  if (item.fileTemplateId == row.fileTemplateId) {
                    //TODO: 不知道为啥，这里直接赋值的话会出不显示
                    arrTmp.push(item);
                  }
                });
              });
              arrTmp.forEach((item) => {
                this.$refs.fileTemTable.toggleRowSelection(item, true);
              });
            });
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
          this.$error(err);
        });
    },
    /**
     * 加载文件模板的表头
     */
    loadColumnData() {
      this.$axios
        .get(`/herp/table/fileTemplate/column/`, {
          headers: {
            operator: this.$util.getLoginer().userid,
            withCredentials: true,
          },
        })
        .then((res) => {
          let data = res.data;
          // 关闭提交表单的loading
          if (data.success) {
            this.fileTemplateColumnData = data.data;
          } else {
            this.$error(data.message);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    /**
     * 点击右侧按钮
     */
    handleClickMore(row, method) {
      this[method](row);
    },
    //表格多选
    handleSelectionChange(val) {
      this.fileTemplateList = val;
    },

    //新增文件模板
    toFileAdd() {
      if (this.formBean.vopCode == "" || this.formBean.ispCode == "") {
        this.$message("请选择基础运营商和虚商");
        return;
      }
      //页面参数
      var pageParam = {
        actType: "add",
        vopId: this.formBean.vopCode,
        ispId: this.formBean.ispCode,
        seleid: "0",
        fileTemplateName: "",
      };
      let commDialog = this.$dialog.commDialog(
        "新增文件模板",
        fileTemplate,
        pageParam,
        "800px",
        "500px"
      );
      commDialog.exec.then((data) => {
        // debugger;
        if(data.type == 'ok')
        this.loadfileTemplate();
      });
    },
    //修改文件模板
    toFileUpd(row) {
      //页面参数
      var pageParam = {
        actType: "upd",
        vopId: this.formBean.vopCode,
        ispId: this.formBean.ispCode,
        seleid: row.fileTemplateId,
        fileTemplateName: row.fileTemplateName,
      };
      let commDialog = this.$dialog.commDialog(
        "修改文件模板",
        fileTemplate,
        pageParam,
        "800px",
        "500px"
      );
      commDialog.exec.then((data) => {
        if(data.type == 'ok')
        this.loadfileTemplate();
      });
    },
  },
};
</script>
